package com.nstar.base.util
{
	import com.sina.microblog.MicroBlog;
	import com.sina.microblog.events.MicroBlogErrorEvent;
	import com.sina.microblog.events.MicroBlogEvent;
	
	import flash.utils.ByteArray;
	
	/**
	 * @description : 新浪微博API接口 Oauth2.0
	 * @date : 2012.1.12
	 * @author : zhuchuanming
	 */ 
	public class WeiboAPIUtils
	{
		public static const GET:String = "GET";
		public static const POST:String = "POST";
		public static var microBlog:MicroBlog;
		
		public function WeiboAPIUtils()
		{
		}
		
		
		
		/*---------------------------- 微博读取接口 ------------------------------------*/
		
		//获取当前登录用户及其所关注用户的最新微博
		/**
		 * feature : 0：全部、1：原创、2：图片、3：视频、4：音乐
		 */ 
		public static function loadFriendsTimeline(sinceId:String="0",maxId:String="0",count:int=50,page:int=1,feature:int = 0 ):void{
			microBlog.callWeiboAPI("2/statuses/friends_timeline",
				{since_id:sinceId,max_id:maxId,count:count,page:page,feature:feature},GET,
				MicroBlogEvent.LOAD_FRIENDS_TIMELINE_RESULT,MicroBlogErrorEvent.LOAD_FRIENDS_TIMELINE_ERROR);
		}
		
		//获取用户发布的微博
		public static function loadUserTimeline(userId:String,screenName:String="",sinceId:String="0",maxId:String="0",count:int=50,page:int=1,feature:int = 0 ):void{
			microBlog.callWeiboAPI("2/statuses/user_timeline",
				{uid:userId,screen_name:screenName,since_id:sinceId,max_id:maxId,count:count,page:page,feature:feature},GET,
				MicroBlogEvent.LOAD_USER_TIMELINE_RESULT,MicroBlogErrorEvent.LOAD_USER_TIMELINE_ERROR);
		}
		
		//根据ID获取单条微博信息
		public static function loadStatus(id:String):void{
			microBlog.callWeiboAPI("2/statuses/show",
				{id:id},GET,
				MicroBlogEvent.LOAD_STATUS_RESULT,MicroBlogErrorEvent.LOAD_STATUS_ERROR);
		}
		
		//按天返回热门转发榜
		public static function loadHotRepostDaily(count:int=20):void{
			microBlog.callWeiboAPI("2/statuses/hot/repost_daily",
				{count:count},GET,
				MicroBlogEvent.LOAD_HOT_REPOST_DAILY_RESULT,MicroBlogErrorEvent.LOAD_HOT_REPOST_DAILY_ERROR);
		}
		//按周返回热门转发榜
		public static function loadHotRepostWeekly(count:int=20):void{
			microBlog.callWeiboAPI("2/statuses/hot/repost_weekly",
				{count:count},GET,
				MicroBlogEvent.LOAD_HOT_REPOST_WEEKLY_RESULT,MicroBlogErrorEvent.LOAD_HOT_REPOST_WEEKLY_ERROR);
		}
		
		//按天返回热门评论榜
		public static function loadHotCommentDaily(count:int=20):void{
			microBlog.callWeiboAPI("2/statuses/hot/comments_daily",
				{count:count},GET,
				MicroBlogEvent.LOAD_HOT_COMMENT_DAILY_RESULT,MicroBlogErrorEvent.LOAD_HOT_COMMENT_DAILY_ERROR);
		}
		//按周返回热门评论榜
		public static function loadHotCommentWeekly(count:int=20):void{
			microBlog.callWeiboAPI("2/statuses/hot/comments_weekly",
				{count:count},GET,
				MicroBlogEvent.LOAD_HOT_COMMENT_WEEKLY_RESULT,MicroBlogErrorEvent.LOAD_HOT_COMMENT_WEEKLY_ERROR);
		}
		
		//批量获取指定微博的转发数评论数
		public static function loadStatusCounts(ids:String):void{
			microBlog.callWeiboAPI("2/statuses/count",
				{ids:ids},GET,
				MicroBlogEvent.LOAD_STATUS_COUNTS_RESULT,MicroBlogErrorEvent.LOAD_STATUS_COUNTS_ERROR);
		}		
		
		/*---------------------------- 微博写入接口 ------------------------------------*/
		//转发一条微博信息
		//isComment:0：否、1：评论给当前微博、2：评论给原微博、3：都评论，默认为0 。
		public static function repostStatus(id:String,status:String,isComment:int=0):void{
			status = encodeURI(status);
			microBlog.callWeiboAPI("2/statuses/repost",
				{id:id,status:status,isComment:isComment},POST,
				MicroBlogEvent.REPOST_STATUS_RESULT,MicroBlogErrorEvent.REPOST_STATUS_ERROR);
		}
		
		//删除微博信息
		public static function deleteStatus(id:String):void{
			microBlog.callWeiboAPI("2/statuses/destroy",
				{id:id},POST,
				MicroBlogEvent.DELETE_STATUS_RESULT,MicroBlogErrorEvent.DELETE_STATUS_ERROR);
		}
		//发布一条微博信息
		public static function updateStatus(status:String):void{
			status = encodeURI(status);
			microBlog.callWeiboAPI("2/statuses/update",
				{status:status},POST,
				MicroBlogEvent.UPDATE_STATUS_RESULT,MicroBlogErrorEvent.UPDATE_STATUS_ERROR);
		}	
		
		//上传图片并发布一条微博
		public static function uploadStatus(status:String,image:ByteArray):void{
			status = encodeURI(status);
			microBlog.callWeiboAPI("2/statuses/upload",
				{status:status,pic:image},POST,
				MicroBlogEvent.UPLOAD_STATUS_RESULT,MicroBlogErrorEvent.UPLOAD_STATUS_ERROR);
		}
		
		//发布一条微博同时指定上传的图片或图片url 
		public static function uploadUrlText(status:String,url:String):void{
			status = encodeURI(status);
			microBlog.callWeiboAPI("2/statuses/upload_url_text",
				{status:status,url:url},POST,
				MicroBlogEvent.UPLOAD_URL_TEXT_RESULT,MicroBlogErrorEvent.UPLOAD_URL_TEXT_ERROR);
		}
		
		//获取官方表情
		public static function emotions(type:String="face"):void{
			microBlog.callWeiboAPI("2/emotions",
				{type:type},GET,
				MicroBlogEvent.UNREAD_COUNT_RESULT,MicroBlogErrorEvent.UNREAD_COUNT_ERROR);
		}		
		/*---------------------------- 评论读取接口 ------------------------------------*/
		//获取某条微博的评论列表
		public static function loadComments(id:String,sinceId:String="0",maxId:String="0",count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/comments/show",
				{id:id,since_id:sinceId,max_id:maxId,count:count,page:page},GET,
				MicroBlogEvent.LOAD_COMMENTS_RESULT,MicroBlogErrorEvent.LOAD_COMMENTS_ERROR);
		}	
		//获取当前登录用户所发出的评论列表
		public static function loadCommentsByMe(sinceId:String="0",maxId:String="0",count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/comments/by_me",
				{since_id:sinceId,max_id:maxId,count:count,page:page},GET,
				MicroBlogEvent.LOAD_COMMENTS_BY_ME_RESULT,MicroBlogErrorEvent.LOAD_COMMENTS_BY_ME_ERROR);
		}
		//获取当前登录用户所发出的评论列表
		public static function loadCommentsToMe(sinceId:String="0",maxId:String="0",count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/comments/to_me",
				{since_id:sinceId,max_id:maxId,count:count,page:page},GET,
				MicroBlogEvent.LOAD_COMMENTS_TO_ME_RESULT,MicroBlogErrorEvent.LOAD_COMMENTS_TO_ME_ERROR);
		}
		//获取当前登录用户的最新评论包括接收到的与发出的
		public static function loadCommentsTimeline(sinceId:String="0",maxId:String="0",count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/comments/timeline",
				{since_id:sinceId,max_id:maxId,count:count,page:page},GET,
				MicroBlogEvent.LOAD_COMMENTS_TIMELINE_RESULT,MicroBlogErrorEvent.LOAD_COMMENTS_TIMELINE_ERROR);
		}
		//获取最新的提到当前登录用户的评论，即@我的评论
		public static function loadCommentsMentions(sinceId:String="0",maxId:String="0",count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/comments/mentions",
				{since_id:sinceId,max_id:maxId,count:count,page:page},GET,
				MicroBlogEvent.LOAD_COMMENTS_MENTIONS_RESULT,MicroBlogErrorEvent.LOAD_COMMENTS_MENTIONS_ERROR);
		}
		//根据评论ID批量返回评论信息
		//cids:需要查询的批量评论ID，用半角逗号分隔，最大50
		public static function loadBatchComments(cids:String){
			microBlog.callWeiboAPI("2/comments/show_batch",
				{cids:cids},GET,
				MicroBlogEvent.LOAD_BATCH_COMMENTS_RESULT,MicroBlogErrorEvent.LOAD_BATCH_COMMENTS_ERROR);
		}
		/*---------------------------- 评论写入接口 ------------------------------------*/
		//对一条微博进行评论
		//commentOri:当评论转发微博时，是否评论给原微博，0：否、1：是，默认为0。
		public static function commentStstus(id:String,comment:String,commentOri:int=0):void{
			comment = encodeURI(comment);
			microBlog.callWeiboAPI("2/comments/create",
				{id:id,comment:comment,comment_ori:commentOri},POST,
				MicroBlogEvent.COMMENT_STATUS_RESULT,MicroBlogErrorEvent.COMMENT_STATUS_ERROR);
		}
		
		//删除一条评论
		public static function deleteComment(cid:String):void{
			microBlog.callWeiboAPI("2/comments/destroy",
				{cid:cid},POST,
				MicroBlogEvent.DELETE_COMMENT_RESULT,MicroBlogErrorEvent.DELETE_COMMENT_ERROR);
		}
		//根据评论ID批量删除评论
		public static function deleteCommentBatch(ids:String):void{
			microBlog.callWeiboAPI("2/comments/destroy_batch",
				{ids:ids},POST,
				MicroBlogEvent.DELETE_COMMENT_BATCH_RESULT,MicroBlogErrorEvent.DELETE_COMMENT_BATCH_ERROR);
		}
		//回复一条评论
		//cid:需要回复的评论ID。
		//id:需要评论的微博ID。
		//commentOri:当评论转发微博时，是否评论给原微博，0：否、1：是，默认为0。
		//withoutMention:回复中是否自动加入“回复@用户名”，0：是、1：否，默认为0。
		public static function replyComment(cid:String,id:String,comment:String,commentOri:int=0,withoutMention:int=0):void{
			comment = encodeURI(comment);
			microBlog.callWeiboAPI("2/comments/reply",
				{cid:cid,id:id,comment:comment,comment_ori:commentOri,without_mention:withoutMention},POST,
				MicroBlogEvent.DELETE_COMMENT_BATCH_RESULT,MicroBlogErrorEvent.DELETE_COMMENT_BATCH_ERROR);
		}
		/*---------------------------- 用户读取接口 ------------------------------------*/
		//获取当前登录用户的UID
		public static function getUID():void{
			microBlog.callWeiboAPI("2/account/get_uid",
				null,GET,
				MicroBlogEvent.VERIFY_CREDENTIALS_RESULT,MicroBlogErrorEvent.VERIFY_CREDENTIALS_ERROR);
		}		
		//查看某用户信息
		public static function loadUser(userId:String):void{
			microBlog.callWeiboAPI("2/users/show",
				{uid:userId},GET,
				MicroBlogEvent.LOAD_USER_INFO_RESULT,MicroBlogErrorEvent.LOAD_USER_INFO_ERROR);
		}
		//批量获取用户的粉丝数、关注数、微博数
		public static function userCounts(uids:String):void{
			microBlog.callWeiboAPI("2/users/counts",
				{uids:uids},GET,
				MicroBlogEvent.LOAD_USER_COUNTS_RESULT,MicroBlogErrorEvent.LOAD_USER_COUNTS_ERROR);
		}		
		/*---------------------------- 关系读取接口 ------------------------------------*/
		//获取用户的关注列表
		//count:单页返回的记录条数，默认为50，最大不超过200。
		//cursor:返回结果的游标，下一页用返回值里的next_cursor，上一页用previous_cursor，默认为0。
		public static function loadFriends(uid:String,screenName:String,count:int=50,cursor:int=0):void{
			microBlog.callWeiboAPI("2/friendships/friends",
				{uid:uid,screen_name:screenName,count:count,cursor:cursor},GET,
				MicroBlogEvent.LOAD_FRIENDS_INFO_RESULT,MicroBlogErrorEvent.LOAD_FRIENDS_INFO_ERROR);
		}
		//获取两个用户之间的共同关注人列表
		//uid:需要获取共同关注关系的用户UID。
		//suid:需要获取共同关注关系的用户UID，默认为当前登录用户。
		public static function loadFriendsInCommon(uid:String,suid:String,count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/friendships/in_common",
				{uid:uid,suid:suid,count:count,page:page},GET,
				MicroBlogEvent.LOAD_FRIENDS_IN_COMMON_RESULT,MicroBlogErrorEvent.LOAD_FRIENDS_IN_COMMON_ERROR);
		}		
		//获取用户的双向关注列表，即互粉列表
		public static function loadFriendsBilateral(uid:String,count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/friendships/friends/bilateral",
				{uid:uid,count:count,page:page},GET,
				MicroBlogEvent.LOAD_FRIENDS_IN_COMMON_RESULT,MicroBlogErrorEvent.LOAD_FRIENDS_IN_COMMON_ERROR);
		}
		//获取用户的粉丝列表
		public static function loadFollowers(uid:String,screenName:String,count:int=50,cursor:int=0):void{
			microBlog.callWeiboAPI("2/friendships/followers",
				{uid:uid,screen_name:screenName,count:count,cursor:cursor},GET,
				MicroBlogEvent.LOAD_FOLLOWERS_INFO_RESULT,MicroBlogErrorEvent.LOAD_FOLLOWERS_INFO_ERROR);
		}
		//获取用户的活跃粉丝列表，即优质粉丝
		public static function loadFollowersActive(uid:String,count:int=20):void{
			microBlog.callWeiboAPI("2/friendships/followers/active",
				{uid:uid,count:count},GET,
				MicroBlogEvent.LOAD_FOLLOWERS_ACTIVE_RESULT,MicroBlogErrorEvent.LOAD_FOLLOWERS_ACTIVE_ERROR);
		}
		//获取两个用户之间的详细关注关系情况
		//参数sourceId与sourceScreenName二者必选其一，且只能选其一
		//参数targetId与targetScreenName二者必选其一，且只能选其一
		public static function loadFriendRelation(sourceId:String,sourceScreenName:String,targetId:String,targetScreenName:String):void{
			microBlog.callWeiboAPI("2/friendships/show",
				{source_id:sourceId,source_screen_name:sourceScreenName,target_id:targetId,target_screen_name:targetScreenName},GET,
				MicroBlogEvent.LOAD_FRIEND_RELATION_RESULT,MicroBlogErrorEvent.LOAD_FRIEND_RELATION_ERROR);
		}
		/*---------------------------- 关系写入接口 ------------------------------------*/	
		//关注某用户
		public static function follow(userId:String):void{
			microBlog.callWeiboAPI("2/friendships/create",
				{uid:userId},POST,
				MicroBlogEvent.FOLLOW_RESULT,MicroBlogErrorEvent.FOLLOW_ERROR);
		}	
		//取消关注一个用户
		public static function cancelfollow(userId:String,screenName:String):void{
			microBlog.callWeiboAPI("2/friendships/destroy",
				{uid:userId,screen_name:screenName},POST,
				MicroBlogEvent.CANCEL_FOLLOWING_RESULT,MicroBlogErrorEvent.CANCEL_FOLLOWING_ERROR);
		}
		
		/*---------------------------- 账号读取接口 ------------------------------------*/
		//获取当前用户API访问频率限制
		public static function getRateLimitStatus():void{
			microBlog.callWeiboAPI("2/account/rate_limit_status",
				null,GET,
				MicroBlogEvent.GET_RATE_LIMIT_STATUS_RESULT,MicroBlogErrorEvent.GET_RATE_LIMIT_STATUS_ERROR);
		}
		//获取所有学校列表
		//type:学校类型，1：大学、2：高中、3：中专技校、4：初中、5：小学，默认为1。
		//capital:学校首字母，默认为A。
		//keyword:学校名称关键字。
		//count:返回的记录条数，默认为10。
		public static function getSchoolList(province:String,city:String,
			area:String,type:String="1",capital:String="A",keyword:String="",count:int = 0):void{
			microBlog.callWeiboAPI("2/account/profile/school_list",
				{province:province,city:city,area:area,type:type,capital:capital,keyword:keyword,count:count},GET,
				MicroBlogEvent.GET_SCHOOL_LIST_RESULT,MicroBlogErrorEvent.GET_SCHOOL_LIST_ERROR);
		}

		/*---------------------------- 账号写入接口 ------------------------------------*/	
		//退出登录
		public static function logout():void{
			microBlog.callWeiboAPI("2/account/end_session",
				null,GET,
				MicroBlogEvent.LOGOUT_RESULT,MicroBlogErrorEvent.LOGOUT_ERROR);
		}
		/*---------------------------- 收藏读取接口 ------------------------------------*/
		//获取当前用户的收藏列表
		public static function loadFavorites(count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/favorites",
				{count:count,page:page},GET,
				MicroBlogEvent.LOAD_FAVORITE_LIST_RESULT,MicroBlogErrorEvent.LOAD_FAVORITE_LIST_ERROR);
		}
		//获取单条收藏信息
		public static function loadOneFavorites(id:String):void{
			microBlog.callWeiboAPI("2/favorites/show",
				{id:id},GET,
				MicroBlogEvent.LOAD_ONE_FAVORITE_LIST_RESULT,MicroBlogErrorEvent.LOAD_ONE_FAVORITE_LIST_ERROR);
		}
		//获取当前用户某个标签下的收藏列表
		public static function loadFavoritesByTags(tid:String,count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/favorites/by_tags",
				{tid:tid,count:count,page:page},GET,
				MicroBlogEvent.LOAD_FAVORITE_LIST_BY_TAGS_RESULT,MicroBlogErrorEvent.LOAD_FAVORITE_LIST_BY_TAGS_ERROR);
		}
		//当前登录用户的收藏标签列表
		public static function loadFavoritesTags(count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/favorites/tags",
				{count:count,page:page},GET,
				MicroBlogEvent.LOAD_FAVORITE_LIST_TAGS_RESULT,MicroBlogErrorEvent.LOAD_FAVORITE_LIST_TAGS_ERROR);
		}

		/*---------------------------- 收藏写入接口 ------------------------------------*/	
		//添加收藏
		public static function addToFavorites(id:String):void{
			microBlog.callWeiboAPI("2/favorites/create",
				{id:id},POST,
				MicroBlogEvent.ADD_TO_FAVORITES_RESULT,MicroBlogErrorEvent.ADD_TO_FAVORITES_ERROR);
		}
		//删除收藏
		public static function removeFavorites(id:String):void{
			microBlog.callWeiboAPI("2/favorites/destroy",
				{id:id},POST,
				MicroBlogEvent.REMOVE_FROM_FAVORITES_RESULT,MicroBlogErrorEvent.REMOVE_FROM_FAVORITES_ERROR);
		}
		//批量删除收藏
		public static function removeFavoritesBatch(ids:String):void{
			microBlog.callWeiboAPI("2/favorites/destroy_batch",
				{ids:ids},POST,
				MicroBlogEvent.REMOVE_FROM_FAVORITES_BATCH_RESULT,MicroBlogErrorEvent.REMOVE_FROM_FAVORITES_BATCH_ERROR);
		}
		//更新一条收藏的收藏标签
		public static function updateFavoritesTags(id:String,tags:String):void{
			microBlog.callWeiboAPI("2/favorites/tags/update",
				{id:id,tags:tags},POST,
				MicroBlogEvent.UPDATE_FAVORITES_TAGS_RESULT,MicroBlogErrorEvent.UPDATE_FAVORITES_TAGS_ERROR);
		}
		//更新当前用户所有收藏下的指定标签
		public static function updateFavoritesTagsBatch(tid:String,tag:String):void{
			microBlog.callWeiboAPI("2/favorites/tags/update_batch",
				{tid:tid,tag:tag},POST,
				MicroBlogEvent.UPDATE_FAVORITES_TAGS_BATCH_RESULT,MicroBlogErrorEvent.UPDATE_FAVORITES_TAGS_BATCH_ERROR);
		}
		//删除当前用户所有收藏下的指定标签
		public static function removeFavoritesTagsBatch(tid:String):void{
			microBlog.callWeiboAPI("2/favorites/tags/destroy_batch",
				{tid:tid},POST,
				MicroBlogEvent.REMOVE_FAVORITES_TAGS_BATCH_RESULT,MicroBlogErrorEvent.REMOVE_FAVORITES_TAGS_BATCH_ERROR);
		}		
		/*---------------------------- 话题读取接口 ------------------------------------*/
		//获取某人话题
		public static function loadTrends(uid:String,count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/trends",
				{uid:uid,count:count,page:page},GET,
				MicroBlogEvent.LOAD_TRENDS_RESULT,MicroBlogErrorEvent.LOAD_TRENDS_ERROR);
		}
		//是否关注某话题
		public static function isFollowTrends(trendName:String):void{
			microBlog.callWeiboAPI("2/trends/is_follow",
				{trend_name:trendName},GET,
				MicroBlogEvent.FOLLOW_TRENDS_RESULT,MicroBlogErrorEvent.FOLLOW_TRENDS_ERROR);
		}		
		//返回最近一小时内的热门话题
		public static function loadTrendsHourly():void{
			microBlog.callWeiboAPI("2/trends/hourly",
				null,GET,
				MicroBlogEvent.LOAD_TRENDS_HOURLY_RESULT,MicroBlogErrorEvent.LOAD_TRENDS_HOURLY_ERROR);
		}
		//返回最近一天内的热门话题
		public static function loadTrendsDayly():void{
			microBlog.callWeiboAPI("2/trends/daily",
				null,GET,
				MicroBlogEvent.LOAD_TRENDS_DAYLY_RESULT,MicroBlogErrorEvent.LOAD_TRENDS_DAYLY_ERROR);
		}
		//返回最近一周内的热门话题
		public static function loadTrendsWeekly():void{
			microBlog.callWeiboAPI("2/trends/weekly",
				null,GET,
				MicroBlogEvent.LOAD_TRENDS_WEEKLY_RESULT,MicroBlogErrorEvent.LOAD_TRENDS_WEEKLY_ERROR);
		}		
		/*---------------------------- 话题写入接口 ------------------------------------*/	
		//关注某话题
		public static function followTrends(trendName:String):void{
			microBlog.callWeiboAPI("2/trends/follow",
				{trend_name:trendName},POST,
				MicroBlogEvent.FOLLOW_TRENDS_RESULT,MicroBlogErrorEvent.FOLLOW_TRENDS_ERROR);
		}
		//取消关注某话题
		public static function cancelTrends(trendId:String):void{
			microBlog.callWeiboAPI("2/trends/destroy",
				{trend_id:trendId},POST,
				MicroBlogEvent.CANCEL_TRENDS_RESULT,MicroBlogErrorEvent.CANCEL_TRENDS_ERROR);
		}
		/*---------------------------- 标签读取接口 ------------------------------------*/
		//获取用户标签
		public static function loadTags(userId:String,count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/tags",
				{uid:userId,count:count,page:page},GET,
				MicroBlogEvent.LOAD_TAGS_RESULT,MicroBlogErrorEvent.LOAD_TAGS_ERROR);
		}
		//批量获取用户的标签列表
		public static function loadTagsBatch(uids:String):void{
			microBlog.callWeiboAPI("2/tags/tags_batch",
				{uids:uids},GET,
				MicroBlogEvent.LOAD_TAGS_BATCH_RESULT,MicroBlogErrorEvent.LOAD_TAGS_BATCH_ERROR);
		}
		
		//获取系统推荐的标签列表
		//count:返回记录数，默认10，最大10。
		public static function loadSuggestionsTags(count:int=10):void{
			microBlog.callWeiboAPI("2/tags/suggestions",
				{count:count},GET,
				MicroBlogEvent.LOAD_SUGGESTIONS_TAGS_RESULT,MicroBlogErrorEvent.LOAD_SUGGESTIONS_TAGS_ERROR);
		}
		/*---------------------------- 标签写入接口 ------------------------------------*/	
		//为当前登录用户添加新的用户标签
		//要创建的一组标签，用半角逗号隔开，每个标签的长度不可超过7个汉字，14个半角字符。
		public static function addTags(tags:String):void{
			microBlog.callWeiboAPI("2/tags/create",
				{tags:tags},POST,
				MicroBlogEvent.ADD_TAGS_RESULT,MicroBlogErrorEvent.ADD_TAGS_ERROR);
		}
		//删除一个用户标签
		public static function deleteTags(tagId:String):void{
			microBlog.callWeiboAPI("2/tags/destory",
				{tag_id:tagId},POST,
				MicroBlogEvent.REMOVE_TAGS_RESULT,MicroBlogErrorEvent.REMOVE_TAGS_ERROR);
		}
		//批量删除用户标签
		public static function deleteTagsBatch(ids:String):void{
			microBlog.callWeiboAPI("2/tags/destory_batch",
				{ids:ids},POST,
				MicroBlogEvent.REMOVE_TAGS_BATCH_RESULT,MicroBlogErrorEvent.REMOVE_TAGS_BATCH_ERROR);
		}
		/*------------------------------ 搜索接口 -------------------------------------*/
		//@用户时的联想建议
		public static function atUsers(qstr:String,type:String="0"):void{
			qstr = encodeURI(qstr);//需要编码
			microBlog.callWeiboAPI("2/search/suggestions/at_users",
				{q:qstr,type:type},GET,
				MicroBlogEvent.UNREAD_COUNT_RESULT,MicroBlogErrorEvent.UNREAD_COUNT_ERROR);
		}
		/*---------------------------- 推荐读取接口 ------------------------------------*/
		//返回系统推荐的热门用户列表
		//推荐分类，返回某一类别的推荐用户，默认为default；如果不在以下分类中，返回空列表。default：人气关注、
		//ent：影视名星、music：音乐、fashion：时尚、literature：文学、business：商界、sports：体育、
		//health：健康、auto：汽车、house：房产、trip：旅行、stock：炒股、food：美食、fate：命理、
		//art：艺术、tech：科技、cartoon：动漫、games：游戏。
		public static function loadUsers(category:String="default"):void{
			microBlog.callWeiboAPI("2/suggestions/users/hot",
				{category:category},GET,
				MicroBlogEvent.LOAD_USERS_HOT_RESULT,MicroBlogErrorEvent.LOAD_USERS_HOT_ERROR);
		}
		//获取用户可能感兴趣的人
		//返回属性说明
		//返回值字段	字段类型	字段说明
		//uid		int64	推荐的用户UID
		//reason	object	推荐原因，有两种格式
		//tag		string	根据标签推荐，按内容推荐（格式1）
		//comp		string	根据公司推荐，按内容推荐（格式1）
		//scho		string	根据学校推荐，按内容推荐（格式1）
		//f			string	按粉丝关系推荐，按关系推荐（格式2）
		//h			string	按关注关系推荐，按关系推荐（格式2）
		//n			int		关联数量，按内容为具有相似内容的数量，按关系为具有相似关系人的数量		
		public static function loadUsersMayInterested(count:int=10,page:int=1):void{
			microBlog.callWeiboAPI("2/suggestions/users/may_interested",
				{count:count,page:page},GET,
				MicroBlogEvent.LOAD_USERS_MAY_INTERESTED_RESULT,MicroBlogErrorEvent.LOAD_USERS_MAY_INTERESTED_ERROR);
		}
		
		//根据一段微博正文推荐相关微博用户
		public static function loadUsersByStatus(content:String,num:int=10):void{
			content = encodeURI(content);
			microBlog.callWeiboAPI("2/suggestions/users/by_status",
				{content:content,num:num},GET,
				MicroBlogEvent.LOAD_USERS_BY_STATUS_RESULT,MicroBlogErrorEvent.LOAD_USERS_BY_STATUS_ERROR);
		}
		//获取微博精选推荐
		public static function loadHotStatus(content:String,num:int=10):void{
			content = encodeURI(content);
			microBlog.callWeiboAPI("2/suggestions/statuses/hot",
				{content:content,num:num},GET,
				MicroBlogEvent.LOAD_HOT_STATUS_RESULT,MicroBlogErrorEvent.LOAD_HOT_STATUS_ERROR);
		}	
		//主Feed微博按兴趣推荐排序
		public static function loadStatusReorder(section:int,count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/suggestions/statuses/reorder",
				{section:section,count:count,page:page},GET,
				MicroBlogEvent.LOAD_STATUS_REORDER_RESULT,MicroBlogErrorEvent.LOAD_STATUS_REORDER_ERROR);
		}
		//返回系统推荐的热门收藏
		public static function loadHotFavorites(count:int=50,page:int=1):void{
			microBlog.callWeiboAPI("2/suggestions/favorites/hot",
				{count:count,page:page},GET,
				MicroBlogEvent.LOAD_HOT_FAVORITES_RESULT,MicroBlogErrorEvent.LOAD_HOT_FAVORITES_ERROR);
		}
		/*---------------------------- 推荐写入接口 ------------------------------------*/	
		//把某人标识为不感兴趣的人
		public static function markNotInterested(uid:String):void{
			microBlog.callWeiboAPI("2/suggestions/users/not_interested",
				{uid:uid},POST,
				MicroBlogEvent.MARK_NOT_INTERESTED_RESULT,MicroBlogErrorEvent.MARK_NOT_INTERESTED_ERROR);
		}
		/*------------------------------- 提醒接口--------------------------------------*/
		//获取用户各种消息未读数
		public static function unreadCount(userId:String):void{
			microBlog.callWeiboAPI("2/remind/unread_count",
				{uid:userId},GET,
				MicroBlogEvent.UNREAD_COUNT_RESULT,MicroBlogErrorEvent.UNREAD_COUNT_ERROR);
		}		
		/*------------------------------- 公共服务--------------------------------------*/
		//通过地址编码获取地址名称
		public static function loadCode2Loaction(codes:String):void{
			microBlog.callWeiboAPI("2/common/code_to_location",
				{codes:codes},GET,
				MicroBlogEvent.LOAD_CODE_2_LOCATION_RESULT,MicroBlogErrorEvent.LOAD_CODE_2_LOCATION_ERROR);
		}	
		//获取城市列表
		//capital:城市的首字母，a-z，可为空代表返回全部，默认为全部
		//language:返回的语言版本，zh-cn：简体中文、zh-tw：繁体中文、english：英文，默认为zh-cn。
		public static function getCity(province:String,capital:String=null,language:String="zh-cn"):void{
			microBlog.callWeiboAPI("2/common/get_city",
				{province:province,capital:capital,language:language},GET,
				MicroBlogEvent.GET_CITY_RESULT,MicroBlogErrorEvent.GET_CITY_ERROR);
		}
		//获取省份列表
		//capital:城市的首字母，a-z，可为空代表返回全部，默认为全部
		//language:返回的语言版本，zh-cn：简体中文、zh-tw：繁体中文、english：英文，默认为zh-cn。
		public static function getProvince(country:String,capital:String=null,language:String="zh-cn"):void{
			microBlog.callWeiboAPI("2/common/get_province",
				{country:country,capital:capital,language:language},GET,
				MicroBlogEvent.GET_PROVINCE_RESULT,MicroBlogErrorEvent.GET_PROVINCE_ERROR);
		}
		//获取省份列表
		//capital:城市的首字母，a-z，可为空代表返回全部，默认为全部
		//language:返回的语言版本，zh-cn：简体中文、zh-tw：繁体中文、english：英文，默认为zh-cn。
		public static function getCountry(capital:String=null,language:String="zh-cn"):void{
			microBlog.callWeiboAPI("2/common/get_country",
				{capital:capital,language:language},GET,
				MicroBlogEvent.GET_COUNTRY_RESULT,MicroBlogErrorEvent.GET_COUNTRY_ERROR);
		}
		/*------------------------------- 地理信息--------------------------------------*/
		//根据关键词查询公交线路信息
		//q:查询的关键词，必须进行URLencode。
		//city:城市代码，默认为北京搜索。
		public static function getBusLine(q:String,city:String="0010",page:int=1,count:int=50):void{
			q = encodeURI(q);
			microBlog.callWeiboAPI("2/location/line/bus_line",
				{q:q,city:city,page:page,count:count},GET,
				MicroBlogEvent.GET_BUS_LINE_RESULT,MicroBlogErrorEvent.GET_BUS_LINE_ERROR);
		}



		/*------------------------------- 自定义方法 --------------------------------------*/
		
		
		//Result事件名称
		private static function getResultEvent(url:String):String{
			return getEvent(url,"Result");
		}
		//Error事件名称
		private static function getErrorEvent(url:String):String{
			return getEvent(url,"Error");
		}		
		
		//根据url返回事件名称
		private static function getEvent(url:String,suffix:String):String{
			var ary:Array = url.split("/");
			var action:String = ary[ary.length-1];//取操作名称
			//将_后面的第一个字母转换成大写
			var startIndex:int = 0;
			var idx:int = action.indexOf("_",startIndex);
			while(idx!=-1){
				var s1:String = action.substr(0,idx);
				var s2:String = action.substr(idx+1,1).toUpperCase();
				var s3:String = action.substr(idx+2);
				action = s1 + s2 + s3;
				
				startIndex = idx+1;
				idx = action.indexOf("_",startIndex);
			}
			return action+suffix;
		}
	}
}